﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Vds2465Telegrams
{
	public class UserData_73_TelegramCounter: UserData_Device
	{
		#region private member variables

		private readonly byte _counter;

		#endregion private member variables

		#region constructor

		public UserData_73_TelegramCounter(byte device, byte counter)
            : base(UserData.UserData73TelegramCounter, device)
		{
			_counter = counter;
		}

		#endregion constructor

		#region getters

		public byte Counter { get { return _counter; } }

		#endregion getters
		
		#region ToString, Equals, GetHashCode

		public override int GetHashCode()
        {
            int hashCode = base.GetHashCode();
			hashCode ^= Counter;
            return hashCode;
        }

        public override string ToString()
        {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.Append("(");
            stringBuilder.Append(ToStringProperties());
            stringBuilder.Append(")");

            return stringBuilder.ToString();
        }

        internal override string ToStringProperties()
        {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.Append(base.ToStringProperties());

			stringBuilder.Append(", ");

			stringBuilder.Append("Counter='");
			stringBuilder.Append(Counter);
			stringBuilder.Append("'");

            return stringBuilder.ToString();
        }

        public override bool Equals(object obj)
        {
            Type objType = obj.GetType();
            if (this.GetType() == objType)
            {
				UserData_73_TelegramCounter userData2Compare = obj as UserData_73_TelegramCounter;
                return EqualsProperties(userData2Compare);
            }

            return false;
        }

		internal bool EqualsProperties(UserData_73_TelegramCounter userData2Compare)
        {
			if (base.EqualsProperties(userData2Compare))
			{
				return (Counter == userData2Compare.Counter);
			}

			return false;
        }

        #endregion ToString, Equals, GetHashCode
	}
}
